package com.cashmama.market.api.infras.utils;

import com.cashmama.market.api.infras.app.RequestBasicInfo;
import com.cashmama.market.api.infras.enums.PackageNameEnum;
import com.cashmama.market.api.infras.enums.order.AppRequestTypeEnum;

import java.util.Objects;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-03-10 16:44
 **/
public class LoanzoneVersionUtils {
    public static boolean version_less_than_or_equal_to_1_0_7(RequestBasicInfo requestBasicInfo) {
        if (requestBasicInfo == null) {
            return false;
        }
        if (!Objects.equals(requestBasicInfo.getPackageName(), PackageNameEnum.LOANZONE.getPackageName())) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() <= 31) {
                return true;
            }
        }

        return false;
    }
}
